function Parent(nickName, age) {
  this.nickName = nickName;
  this.age = age;
}
Parent.prototype.getNickName = function() {
  return this.nickName;
};

function Child(price) {
  this.price = price;
}

Child.prototype = new Parent('seven', 26);

var c1 = new Child(25);
console.log(c1);
c1.__proto__.getNickName(); // seven

// 借用构造函数继承

function Parent(nickName, age) {
  this.nickName = nickName;
  this.age = age;
}
Parent.prototype.getNickName = function() {
  return this.nickName;
};
function Parent1(sex) {
  this.sex = sex;
}

function Child(nickName, age, sex, price) {
  Parent.call(this, nickName, age);
  Parent1.call(this, sex);
  this.price = price;
}

var c1 = new Child(25, 'seven', 'girl', 26);

// 原型链 + 借用构造函数的组合继承

function Parent(nickName, age) {
  this.nickName = nickName;
  this.age = age;
}
Parent.prototype.getNickName = function() {
  return this.nickName;
};

function Child(nickName, age, price) {
  Parent.call(this, nickName, age);
  this.price = price;
}

Child.prototype = new Parent();
Child.prototype.construtor = Child;
Child.prototype.sayHi = function() {};

var c1 = new Child(25, 'seven', 26);

// 原型式继承

function object(o) {
  function F() {}
  F.prototype = o;
  return new F();
}

let person = {
  nickName: 'seven',
  friend: ['1', '3'],
};
let p1 = object(person);

// 寄生式继承
function object(o) {
  function F() {}
  F.prototype = o;
  return new F();
}

function objectFactory(o) {
  let clone = object(o);
  clone.sayHi = function() {
    console.log('hi');
  };
  return clone;
}

let person = {
  nickName: 'seven',
  friends: ['Tom', 'JHon'],
};

let p2 = objectFactory(person);
